package com.example.siyun.controller.commentcontroller;

import com.example.siyun.pojo.SyComment;
import com.example.siyun.service.commentservice.PersonalService;
import com.example.siyun.util.JsonResult;
import com.example.siyun.util.PageResult;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 个人评论
 *@author：王浩宇
 *@Date: 2022-10-12
 * */
@RestController
@RequestMapping("/personal")
@Slf4j
public class CommentPersonalController {

    @Autowired
    private PersonalService personalService;
    /**
     * 获取全部课程评论
     * @page:页数
     * @limit:条数
     * */
    @RequestMapping("/get")
    public PageResult<List> get(Integer page, Integer limit){

        PageHelper.startPage(page, limit);
        List<SyComment> all = personalService.Get();

        PageInfo<SyComment> pageInfo = new PageInfo<>(all);

        PageResult<List> pageResult = new PageResult<>();
        pageResult.setMessage("成功");
        pageResult.setData(pageInfo.getList());
        pageResult.setState(0);
        pageResult.setTotal(pageInfo.getTotal());

        return pageResult;
    }
    /**
     *通过
     * @id:主键id
     * */
    @RequestMapping("/adopt")
    public void updateadopt(Integer id){
        personalService.updateAdopt(id);
        log.info(id+"状态改为通过");
    }
    /**
     *拦截
     *@id:主键id
     * */
    @RequestMapping("/intercep")
    public void updateintercep(Integer id){
        personalService.updateIntercept(id);
        log.info(id+"状态改为拦截");
    }
    /**
     *删除
     *@id:主键id
     * */
    @RequestMapping("/delete")
    public void updatedelete(Integer id){
        personalService.updateDelete(id);
        log.info(id+"状态改为删除");
    }
    /**
     *历史评论次数
     * */
    @RequestMapping("/countAll")
    public JsonResult<Integer> count(){
        int a = personalService.Count();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *已通过全部评论
     * @page:页数
     * @limit:条数
     * */
    @RequestMapping("/getadopt")
    public PageResult<List> getByadopt(Integer page, Integer limit){

        PageHelper.startPage(page, limit);
        List<SyComment> all = personalService.getAdopt();

        PageInfo<SyComment> pageInfo = new PageInfo<>(all);

        PageResult<List> pageResult = new PageResult<>();
        pageResult.setMessage("成功");
        pageResult.setData(pageInfo.getList());
        pageResult.setState(0);
        pageResult.setTotal(pageInfo.getTotal());

        return pageResult;
    }
    /**
     *已通过全部历史评论次数
     * */
    @RequestMapping("/countadopt")
    public JsonResult<Integer> countByadopt(){
        int a = personalService.countAdopt();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *已拦截全部评论
     * @page:页数
     * @limit:条数
     * */
    @RequestMapping("/getintercept")
    public PageResult<List> getByintercept(Integer page, Integer limit){

        PageHelper.startPage(page, limit);
        List<SyComment> all = personalService.getIntercept();

        PageInfo<SyComment> pageInfo = new PageInfo<>(all);

        PageResult<List> pageResult = new PageResult<>();
        pageResult.setMessage("成功");
        pageResult.setData(pageInfo.getList());
        pageResult.setState(0);
        pageResult.setTotal(pageInfo.getTotal());

        return pageResult;
    }
    /**
     *已拦截全部历史评论次数
     * */
    @RequestMapping("/countintercept")
    public JsonResult<Integer> countByintercept(){
        int a = personalService.countIntercept();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *已删除全部评论
     * @page:页数
     * @limit:条数
     * */
    @RequestMapping("/getdelete")
    public PageResult<List> getBydelete(Integer page, Integer limit){

        PageHelper.startPage(page, limit);
        List<SyComment> all = personalService.getDelete();

        PageInfo<SyComment> pageInfo = new PageInfo<>(all);

        PageResult<List> pageResult = new PageResult<>();
        pageResult.setMessage("成功");
        pageResult.setData(pageInfo.getList());
        pageResult.setState(0);
        pageResult.setTotal(pageInfo.getTotal());

        return pageResult;
    }
    /**
     *已删除全部历史评论次数
     * */
    @RequestMapping("/countdelete")
    public JsonResult<Integer> countBydelete(){
        int a = personalService.countDelete();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *历史评论人数
     * */
    @RequestMapping("/countpeople")
    public JsonResult<Integer> countPeople(){
        int a = personalService.countPeople();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *已通过全部历史评论人数
     * */
    @RequestMapping("/countpeopleadopt")
    public JsonResult<Integer> counttwoByadopt(){
        int a = personalService.countPeopleAdopt();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *已拦截全部历史评论人数
     * */
    @RequestMapping("/countpeopleintercept")
    public JsonResult<Integer> counttwoByintercept(){
        int a = personalService.countPeopleIntercept();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *已删除全部历史评论人数
     * */
    @RequestMapping("/countpeopledelete")
    public JsonResult<Integer> counttwoBydelete(){
        int a = personalService.countPeopleDelete();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *今日评论次数
     * */
    @RequestMapping("/counttoday")
    public JsonResult<Integer> countthree(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = personalService.countToday(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *今日评论人数
     * */
    @RequestMapping("/counttodaypeople")
    public JsonResult<Integer> countfour(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = personalService.countTodayPeople(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }

    /**
     *已通过今日评论次数
     * */
    @RequestMapping("/counttodayadopt")
    public JsonResult<Integer> countthreeByadopt(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = personalService.countTodayAdopt(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *已通过今日评论人数
     * */
    @RequestMapping("/counttodaypeopleadopt")
    public JsonResult<Integer> countfourByadopt(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = personalService.countTodayPeopleAdopt(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *已拦截今日评论次数
     * */
    @RequestMapping("/counttodayintercept")
    public JsonResult<Integer> countthreeByintercept(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = personalService.countTodayIntercept(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *已拦截今日评论人数
     * */
    @RequestMapping("/counttodaypeopleintercept")
    public JsonResult<Integer> countfourByintercept(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = personalService.countTodayPeopleIntercept(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *已删除今日评论次数
     * */
    @RequestMapping("/counttodaydelete")
    public JsonResult<Integer> countthreeBydelete(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = personalService.countTodayDelete(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *已删除今日评论人数
     * */
    @RequestMapping("/counttodaypeopledelete")
    public JsonResult<Integer> countfourBydelete(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = personalService.countTodayPeopleDelete(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *前端用户全部评论
     * @page:页数
     * @limit:条数
     * */
    @RequestMapping("/reception")
    public PageResult<List> reception(Integer page, Integer limit){
        Map<String, Object> map = new HashMap<>();

        PageHelper.startPage(page, limit);
        List<SyComment> all = personalService.Reception();

        PageInfo<SyComment> pageInfo = new PageInfo<>(all);

        PageResult<List> pageResult = new PageResult<>();
        pageResult.setMessage("成功");
        pageResult.setData(pageInfo.getList());
        pageResult.setState(0);
        pageResult.setTotal(pageInfo.getTotal());

        return pageResult;
    }
    /**
     *前端用户历史评论次数
     * */
    @RequestMapping("/countreception")
    public JsonResult<Integer> countByreceptione(){
        int a = personalService.countReception();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *前端用户历史评论人数
     * */
    @RequestMapping("/countpeoplereception")
    public JsonResult<Integer> counttwoByreception(){
        int a = personalService.countPeopleReception();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *前端用户今日评论次数
     * */
    @RequestMapping("/counttodayreception")
    public JsonResult<Integer> countthreeByreception(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = personalService.countTodayReception(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *前端用户今日评论人数
     * */
    @RequestMapping("/counttodaypeoplereception")
    public JsonResult<Integer> countfourByreception(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = personalService.countTodayPeopleReception(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *后台人员全部评论
     * @page:页数
     * @limit:条数
     * */
    @RequestMapping("/backstage")
    public PageResult<List> backstage(Integer page, Integer limit){

        PageHelper.startPage(page, limit);
        List<SyComment> all = personalService.Backstage();

        PageInfo<SyComment> pageInfo = new PageInfo<>(all);

        PageResult<List> pageResult = new PageResult<>();
        pageResult.setMessage("成功");
        pageResult.setData(pageInfo.getList());
        pageResult.setState(0);
        pageResult.setTotal(pageInfo.getTotal());

        return pageResult;
    }
    /**
     *后台人员历史评论次数
     * */
    @RequestMapping("/countbackstage")
    public JsonResult<Integer> countBybackstage(){
        int a = personalService.countBackstage();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *后台人员历史评论人数
     * */
    @RequestMapping("/countpeoplebackstage")
    public JsonResult<Integer> counttwoBybackstage(){
        int a = personalService.countPeopleBackstage();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *后台人员今日评论次数
     * */
    @RequestMapping("/counttodaybackstage")
    public JsonResult<Integer> countthreeBybackstage(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = personalService.countTodayBackstage(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *后台人员今日评论人数
     * */
    @RequestMapping("/counttodaypeoplebackstage")
    public JsonResult<Integer> countfourBybackstage(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = personalService.countTodayPeopleBackstage(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *课程评论数据
     * @page:页数
     * @limit:条数
     * */
    @RequestMapping("/curriculum")
    public PageResult<List> curriculum(Integer page, Integer limit){
        Map<String, Object> map = new HashMap<>();

        PageHelper.startPage(page, limit);
        List<SyComment> all = personalService.Curriculum();

        PageInfo<SyComment> pageInfo = new PageInfo<>(all);

        PageResult<List> pageResult = new PageResult<>();
        pageResult.setMessage("成功");
        pageResult.setData(pageInfo.getList());
        pageResult.setState(0);
        pageResult.setTotal(pageInfo.getTotal());

        return pageResult;
    }
    /**
    * 课程历史评论次数
    * */
    @RequestMapping("/countcurriculum")
    public JsonResult<Integer> countcurriculum(){
        int a = personalService.countCurriculum();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }

    /**
     * 课程历史评论人数
     * */
    @RequestMapping("/countpeoplecurriculum")
    public JsonResult<Integer> countpeoplecurriculum(){
        int a = personalService.countPeopleCurriculum();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }

    /**
     * 课程今日评论次数
     * */
    @RequestMapping("/counttodaycurriculum")
    public JsonResult<Integer> counttodaycurriculum(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = personalService.countTodayCurriculum(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     * 课程今日评论人数
     * */
    @RequestMapping("/counttodaypeoplecurriculum")
    public JsonResult<Integer> counttodaypeoplecurriculum(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = personalService.countTodayPeopleCurriculum(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     * 商品评论数据
     * @page:页数
     * @limit:条数
     * */
    @RequestMapping("/commodity")
    public PageResult<List> commodity(Integer page, Integer limit){

        PageHelper.startPage(page, limit);
        List<SyComment> all = personalService.Commodity();

        PageInfo<SyComment> pageInfo = new PageInfo<>(all);

        PageResult<List> pageResult = new PageResult<>();
        pageResult.setMessage("成功");
        pageResult.setData(pageInfo.getList());
        pageResult.setState(0);
        pageResult.setTotal(pageInfo.getTotal());

        return pageResult;
    }
    /**
     * 商品评论历史评论次数
     * */
    @RequestMapping("/countcommodity")
    public JsonResult<Integer> countcommodity(){
        int a = personalService.countCommodity();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }

    /**
     * 商品评论历史评论人数
     * */
    @RequestMapping("/countpeoplecommodity")
    public JsonResult<Integer> countpeoplecommodity(){
        int a = personalService.countPeopleCommodity();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }

    /**
     * 商品评论今日评论次数
     * */
    @RequestMapping("/counttodaycommodity")
    public JsonResult<Integer> counttodaycommodity(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = personalService.countTodayCommodity(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     * 商品评论今日评论人数
     * */
    @RequestMapping("/counttodaypeoplecommodity")
    public JsonResult<Integer> counttodaypeoplecommodity(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = personalService.countTodayPeopleCommodity(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     * 微圈评论数据
     * @page:页数
     * @limit:条数
     * */
    @RequestMapping("/microcircle")
    public PageResult<List> microcircle(Integer page, Integer limit){

        PageHelper.startPage(page, limit);
        List<SyComment> all = personalService.Microcircle();

        PageInfo<SyComment> pageInfo = new PageInfo<>(all);

        PageResult<List> pageResult = new PageResult<>();
        pageResult.setMessage("成功");
        pageResult.setData(pageInfo.getList());
        pageResult.setState(0);
        pageResult.setTotal(pageInfo.getTotal());

        return pageResult;
    }
    /**
     * 微圈评论历史评论次数
     * */
    @RequestMapping("/countmicrocircle")
    public JsonResult<Integer> countmicrocircle(){
        int a = personalService.countMicrocircle();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }

    /**
     * 微圈评论历史评论人数
     * */
    @RequestMapping("/countpeoplemicrocircle")
    public JsonResult<Integer> countpeoplemicrocircle(){
        int a = personalService.countPeopleMicrocircle();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }

    /**
     * 微圈评论今日评论次数
     * */
    @RequestMapping("/counttodaymicrocircle")
    public JsonResult<Integer> counttodaymicrocircle(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = personalService.countTodayMicrocircle(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     * 微圈评论今日评论人数
     * */
    @RequestMapping("/counttodaypeoplemicrocircle")
    public JsonResult<Integer> counttodaypeoplemicrocircle(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = personalService.countTodayPeopleMicrocircle(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }

}
